package com.uuah.server.exception.transformer;

import java.util.List;

import com.uuah.config.i18n.Message;
import com.uuah.server.api.transformer.IBaseTransformer;
import com.uuah.server.exception.endpoint.EndpointException;
import com.uuah.server.transformer.TransformerUtils;

/**
 * <code>TransformerException</code> is a simple exception that is thrown by
 * transformers.
 *
 * <p>
 * update record:updator，update time，update content and version
 * </p>
 *
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2009 2009-3-27 下午01:42:37
 * @version 1.0.0
 */
public class TransformerException extends EndpointException {
	private static final String TRANSFORMER = "Transformer";
	private static final long serialVersionUID = 2943589828020763649L;

	private transient IBaseTransformer transformer;

	public TransformerException(Message message, IBaseTransformer transformer) {
		super(message);
		this.transformer = transformer;
	}

	public TransformerException(Message message, List transformers) {
		super(message);
		this.transformer = TransformerUtils.firstOrNull(transformers);
	}

	/**
	 * @param message
	 *            the exception message
	 * @param cause
	 *            the exception that cause this exception to be thrown
	 */
	public TransformerException(Message message, IBaseTransformer transformer,
			Throwable cause) {
		super(message, cause);
		this.transformer = transformer;
	}

	public TransformerException(Message message, List transformers,
			Throwable cause) {
		super(message, cause);
		this.transformer = TransformerUtils.firstOrNull(transformers);
	}

	public TransformerException(IBaseTransformer transformer, Throwable cause) {
		super(cause);
		this.transformer = transformer;
	}

	public TransformerException(List transformers, Throwable cause) {
		super(cause);
		this.transformer = TransformerUtils.firstOrNull(transformers);
	}

	/**
	 * @param message
	 *            the exception message
	 * @param cause
	 *            the exception that cause this exception to be thrown
	 */
	public TransformerException(Message message, Throwable cause) {
		super(message, cause);
	}

	/**
	 * @param message
	 *            the exception message
	 */
	public TransformerException(Message message) {
		super(message);
	}

	public IBaseTransformer getTransformer() {
		return transformer;
	}
}
